//
//  TipsCenter.m
//  MerchantTemplate
//
//  Created by Gan LL on 13-4-24.
//  Copyright (c) 2013年 zdsoft. All rights reserved.
//

#import "TipsCenter.h"
#import "UINoticeTextUtil.h"

TipsCenter *_defaultCenter = nil;

@implementation TipsCenter
{
    
}


+ (TipsCenter *)center
{
    if (_defaultCenter == nil)
    {
        _defaultCenter = [[TipsCenter alloc] init];
    }
    return _defaultCenter;
}

- (id)init
{
    self = [super init];
    if (self)
    {
        if (_defaultCenter != nil)
        {
            [self release];
            return nil;
        }
    }
    return self;
}

- (void)addTip:(NSString *)tipStr level:(ZDTipsLevel)tipLv
{
    switch (tipLv)
    {
        case ZDTipsLevelNotice:
        case ZDTipsLevelWarning:
        {
            [[UINoticeTextUtil sharedInstance] showWithText:tipStr stay:0.5 offset:SCREEN_HEIGHT/2];
        }
            break;
        case ZDTipsLevelSuccess:
        {
            [[UINoticeTextUtil sharedInstance] showWithText:tipStr stay:0.5 offset:SCREEN_HEIGHT/2  TipsLevel:ZDTipsLevelSuccess];
        }
            break;
        case ZDTipsLevelAlert:
        {
            [[[[UIAlertView alloc] initWithTitle:@"警告"
                                         message:tipStr
                                        delegate:nil
                               cancelButtonTitle:nil
                               otherButtonTitles:@"好的", nil] autorelease] show];
        }
            break;
        default:
            break;
    }

}

- (void)addTip:(NSString *)tipStr level:(ZDTipsLevel)tipLv offset:(CGFloat)offset
{
    switch (tipLv)
    {
        case ZDTipsLevelNotice:
        case ZDTipsLevelWarning:
        {
            [[UINoticeTextUtil sharedInstance] showWithText:tipStr stay:2.0 offset:offset];
        }
            break;
        case ZDTipsLevelSuccess:
        {
            [[UINoticeTextUtil sharedInstance] showWithText:tipStr stay:2.0 offset:offset TipsLevel:ZDTipsLevelSuccess];
        }
            break;
        case ZDTipsLevelAlert:
        {
            [[[[UIAlertView alloc] initWithTitle:@"警告"
                                         message:tipStr
                                        delegate:nil
                               cancelButtonTitle:nil
                               otherButtonTitles:@"好的", nil] autorelease] show];
        }
       
        default:
            break;
    }
    
}

@end
